package com.mall.order.service.impl;

import ch.qos.logback.core.pattern.ConverterUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mall.common.page.PageData;
import com.mall.common.service.impl.CrudServiceImpl;
import com.mall.common.utils.ConvertUtils;
import com.mall.common.vo.UserInfoVo;
import com.mall.order.dao.OrderItemDao;
import com.mall.order.dto.OrderItemDTO;
import com.mall.order.entity.OrderItemEntity;
import com.mall.order.interceptor.OrderInterceptor;
import com.mall.order.service.OrderItemService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 订单项信息
 *
 * @author xjc xjc@163.com
 * @since 1.0.0 2022-07-17
 */
@Service
public class OrderItemServiceImpl extends CrudServiceImpl<OrderItemDao, OrderItemEntity, OrderItemDTO> implements OrderItemService {

    @Override
    public QueryWrapper<OrderItemEntity> getWrapper(Map<String, Object> params) {
        String id = (String) params.get("id");

        QueryWrapper<OrderItemEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id);

        return wrapper;
    }


    @Override
    public List<OrderItemDTO> getPage(List<String> orderSns) {
        List<OrderItemEntity> list = baseDao.selectByOrderSn(orderSns);
        return ConvertUtils.sourceToTarget(list, OrderItemDTO.class);
    }
}